package com.review.Test.Provider_Consumer;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		LinkedBlockingQueue<Data> queue = new LinkedBlockingQueue<>();
		Provider p1 = new Provider(queue);
		Provider p2 = new Provider(queue);
		Provider p3 = new Provider(queue);
		
		Consumer c1 = new Consumer(queue);
		Consumer c2 = new Consumer(queue);
		Consumer c3 = new Consumer(queue);
		
		ExecutorService pool = Executors.newCachedThreadPool();
		pool.execute(p1);
		pool.execute(p2);
		pool.execute(p3);
		pool.execute(c1);
		pool.execute(c2);
		pool.execute(c3);
		
		Thread.sleep(3000);
		p1.stop();
		p2.stop();
		p3.stop();
		
		
		
	}

}
